import { resetRouter, routes } from '@/router'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { RouteRecordRaw } from 'vue-router'



// 侧栏菜单 Store（请忽略类型报错，这是 pnpm 工具的问题）
export const useMenuStore = defineStore('hm-menu', () => {
	const menuList = ref<RouteRecordRaw[]>([...routes])

	const setMenuList = (filterRoutes: RouteRecordRaw[]) => {
		menuList.value = [...menuList.value, ...filterRoutes]
	}
	// 重置菜单和路由
	const clearMenuList = () => {
		menuList.value = [...routes]
		resetRouter()
	}
	return {
		menuList,
		setMenuList,
		clearMenuList
	}
})
